package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.ReportBusinessData;
import com.itheima.pojo.ReportMemberVO;
import com.itheima.pojo.ReportSetmealVO;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController("backendReportController")
@Slf4j
@RequestMapping("/report")
public class ReportController {
    @Autowired
    ReportService reportService;

    @GetMapping("/getMemberReport")
    Result getMemberReport() {
        log.info("获取会员数量统计数据");
        ReportMemberVO reportMemberVO = reportService.getMemberReport();
        return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS, reportMemberVO);
    }

    @GetMapping("/getSetmealReport")
    Result getSetmealReport() {
        log.info("获取套餐占比统计数据");
        ReportSetmealVO reportSetmealVO = reportService.getSetmealReport();
        return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS, reportSetmealVO);
    }

    @GetMapping("/getBusinessReportData")
    Result getBusinessReportData() {
        log.info("获取运营统计数据");
        ReportBusinessData reportBusinessData = reportService.getBusinessReportData();
        return new Result(true, MessageConstant.GET_BUSINESS_REPORT_SUCCESS, reportBusinessData);
    }

    @GetMapping("/exportBusinessReport")
    void exportBusinessReport(HttpServletResponse response) {
        log.info("导出运营数据");
        reportService.exportBusinessReport(response);
        //  return new Result(true, MessageConstant.GET_BUSINESS_REPORT_SUCCESS);
    }
}
